package com.nirvana.admin;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author: zhangshuaiyin
 * @date: 2021/5/31 21:43
 */
@Slf4j
@SpringBootApplication(scanBasePackages = {"com.nirvana"})
public class NirvanaAdminApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(NirvanaAdminApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        port = port == null ? "8080" : port;
        String path = env.getProperty("server.servlet.context-path");
        path = path == null ? "" : path;
        log.info("\n=========================================================\n\t" +
                "Application is running! Access URLs:\n\t" +
                "本地访问地址: \thttp://localhost:" + port + path + "/\n\t" +
                "外部访问地址: \thttps://" + ip + ":" + port + path + "/\n\t" +
                "Swagger文档: \thttp://localhost:" + port + path + "/doc.html\n" +
                "=========================================================");
    }

}
